#include <QHBoxLayout>
#include <QVBoxLayout>
#include "common.h"
#include "fileframe.h"
#include "previewframe.h"
#include "controlframe.h"
#include "statusframe.h"
#include "centerwindow.h"

CenterWindow::CenterWindow(QWidget *parent) :
    QWidget(parent)
{
    this->setMinimumSize(850, 450);
    m_pFileFrame = new FileFrame();
    m_pPreviewFrame = new PreviewFrame();
    m_pControlFrame = new ControlFrame();
    m_pStatusFrame = new StatusFrame();
    connect(this, SIGNAL(signalLanguageChanged()), m_pFileFrame, SIGNAL(signalLanguageChanged()));

    QHBoxLayout *horizontalLayout = new QHBoxLayout;
    horizontalLayout->addWidget(m_pFileFrame);
    horizontalLayout->addWidget(m_pPreviewFrame);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(horizontalLayout);
    mainLayout->addWidget(m_pControlFrame);
    mainLayout->addWidget(m_pStatusFrame);

    this->setLayout(mainLayout);

    connect(m_pFileFrame, SIGNAL(signalFileSelectionChanged(bool,bool)), this, SIGNAL(signalFileSelectionChanged(bool,bool)));
}

void CenterWindow::addFileList(const QStringList &filelist)
{
    m_pFileFrame->addFileList(filelist);
}

void CenterWindow::addDirectory(const QString &path)
{
    m_pFileFrame->addDirectory(path);
}

void CenterWindow::deleteSelectedFiles()
{
    if (m_pFileFrame){
        m_pFileFrame->deleteSelectedFiles();
    }
}
